package com.hbnu.tagyalu;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class OutputStreamWriterDemo {
    public static void main(String[] args) {
        String path="D:"+File.separator+"program"+File.separator+"tttt.txt";
        File file=new File(path);
        OutputStreamWriter outputStreamWriter=null;
        try {
            outputStreamWriter=new OutputStreamWriter(new FileOutputStream(file,true));
            String str="hwll";
            outputStreamWriter.write(str);
            System.out.println("文件写入成功");
        }
        catch (Exception e){
            e.printStackTrace();
        }
        finally {
            try {
                if (outputStreamWriter!=null){
                    outputStreamWriter.close();
                }
            }
            catch (IOException e){
                e.printStackTrace();
            }
        }
    }
}
